<template>
    <div>
        <h4>发表评论</h4>
        <hr>

        <textarea id="textarea" rows="5" placeholder="请输入你要BB的 内容"></textarea>

       <button class="mint-button mint-button--primary mint-button--large"><!----> <label class="mint-button-text">发表评论</label></button>

        <div class="cs-comment" v-for="(item, index) in Publish" :key="index">
            <p class="cs-user">
                <span>第{{index+1}}楼 </span>
                <span>用户: {{Publish.user_name}}</span>
                <span>发表时间: {{Publish.add_time}}</span>
            </p>
            <p class="cs-postedTime">
                {{ !item.content?'这个人不喜欢BB':item.content}}
            </p>
        </div>

       

        <button class="mint-button mint-button--danger mint-button--large is-plain" @click="getMor"> <label class="mint-button-text">加载更多</label></button>
    </div>
</template>

<script>
export default {
    created(){
        this. Published()
    },
    data () {
        return {
            pageIndex:1,
            Publish:[]
        }
    },
    methods:{
        Published(){
            this.$http.get("api/getcomments/"+this.id+"?pageindex="+this.pageIndex).then((result) => {
                console.log(result);
                this.Publish=this.Publish.concat(result.data.message)
            }).catch((err) => {
                
            });
        },
        getMor(){
             this.pageIndex++;
            this.Published()
        }
    },
    props:["id"]
}
</script>

